<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return['member']=pdo_get('jy_renwushop_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
if($return['member']['jsjiqi']){
	if($return['member']['jiqiendtime'] && $return['member']['jiqiendtime']<TIMESTAMP){
		$return['isendjiqi']=1;
	}
}
if($_RQ['op']=='main'){
	$return['type']=0;
	exi($return);
}
/*******op*******/
if($_RQ['op']=='list'){
	//超时未支付订单取消
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	//查询进入该页面的客户所有订单
	$params=array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']);
	if(isset($_RQ['status']) && $_RQ['status'] != 10){
		$params['status']=intval($_RQ['status']);
		$return['status']=$_RQ['status'];
	}else{
		$return['status']=10;
	}
	if($return['member']['jsjiqi']!=1 && $_RQ['type']==1){
		$return['list']=array();
		exi($return);
	}
	$table=intval($_RQ['type'])?'jy_renwushop_canyu':'jy_renwushop_yuyue';
	$list=pdo_getslice($table,$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($list){
		$fields=array('id','title','image','price','active_plugin','active_id','salenum','originalprice','usermaxbuy','unit');
		foreach($list as &$item){
			$item['member']=cfc('core')->member_show($item['mid']);
			$item['goods']=pdo_get('jy_renwushop_renwu',array('id'=>$item['pingid'],'uniacid'=>$_SESSION['uniacid']));
			$goods=model('jy_weishop/goods')->goods_detail($item['goods']['goodsid'],$fields);
			$item['goods']['goodsprice']=$goods['price'];
			$item['goods']['image']=$goods['image'];
			$item['goods']['title']=$goods['title'];
			$item['goods']=$this->model('model')->up_safeprice($item['goods'],$return['pluginset'],true);
			$item['createtime']=date('Y-m-d H:i:s', $item['createtime']);
			$item['statustitle']=$this->yuyue_status[$item['status']];
		}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='del'){
	if(!$_RQ['id']){
		exi('预约不存在，请重新选择订单','error');
	}
	pdo_delete('jy_renwushop_canyu',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	exi('取消参与成功');
}